package com.m7788.util;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class ResizeLayout extends LinearLayout{ 
    private static int count = 0; 
    private OnSizeChangeListener listener;
    private Context mContext;
    public ResizeLayout(Context context, AttributeSet attrs) { 
        super(context, attrs); 
        this.mContext = context;
    } 
     

	public void setOnSizeChangeListener(OnSizeChangeListener listener) {
		this.listener = listener;
	}

	@Override 
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {     
        super.onSizeChanged(w, h, oldw, oldh); 
        if(listener!=null)
        	listener.sizeChange(w, h, oldw, oldh);
//        Log.e("onSizeChanged " + count++, "=>onResize called! w="+w + ",h="+h+",oldw="+oldw+",oldh="+oldh); 
    } 
    @Override 
    protected void onLayout(boolean changed, int l, int t, int r, int b) { 
        super.onLayout(changed, l, t, r, b); 
//        Log.e("onLayout " + count++, "=>OnLayout called! l=" + l + ", t=" + t + ",r=" + r + ",b="+b); 
    } 
     
    @Override 
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
        super.onMeasure(widthMeasureSpec, heightMeasureSpec); 
         
//        Log.e("onMeasure " + count++, "=>onMeasure called! widthMeasureSpec=" + widthMeasureSpec + ", heightMeasureSpec=" + heightMeasureSpec); 
    } 
    
    
    public interface OnSizeChangeListener {
		public void sizeChange(int w, int h, int oldw, int oldh);
	}
}